<template>
	<view class="content" v-show="show">
		<!-- 头部导航 -->
		<view class="w-750 w-bj-cont" style="position: fixed; top: 0; left: 0;z-index: 999;">
			<view class="h-100 w-row-justify-between-align">
				<view class="wh-80 w-row-center" @click="routerBack()">
					<image class="wh-40" src="../../../static/gane/fh.png"></image>
				</view>
				<view class="w-250 h-100 w-row-center w-wz-conts font-36">
					<text>订单记录</text>
				</view>
				<view class="wh-80 w-row-center">
					<uni-datetime-picker type="datetimerange" @change="changeTiem">
						<image class="wh-50" src="../../../static/gane/rq.png"></image>
					</uni-datetime-picker>
				</view>
			</view>
		</view>
		<view class="bwh-120"></view>
		<!-- 头部导航结束 -->

		<!-- 内容区域 -->
		<view class="w-720 w-bj-cont w-bor-12 w-column-align m-bottom-20 font-24 w-wz-conts"
			v-for="(item,index) in tableData">
			<view class="h-10"></view>

			<view class="w-680 p-2 w-row-justify-between-align">
				<text class="font-30b w-wz-white">期号{{item.issue}}</text>
				<view class="w-wz-black8" style="display: flex;align-items: center;">
					
					<text style="border: solid 2rpx #ffffff; padding: 5rpx 10rpx; border-radius: 2rpx; color: #ffffff;"  v-if="item.status == 2 || item.status == 3">结果 {{item.issue_number}}</text> <text class="p-2"></text>
					
					<text v-if="item.status == 1"><image class="w-130" src="../../../static/gane/order_wzj_kcd.png" mode="aspectFill" style="height: 45rpx;"></image></text>
					
					<text v-if="item.status == 2"><image class="w-100" src="../../../static/gane/order_yzj.png" mode="aspectFill" style="height: 45rpx;"></image></text>
					
					<text v-if="item.status == 3"><image class="w-100" src="../../../static/gane/order_wzj.png" mode="aspectFill" style="height: 45rpx;"></image></text>
					
                    <text style="border: solid 2rpx #ffaa00; padding: 5rpx 10rpx; border-radius: 2rpx; color: #ffaa00;"  v-if="item.status == 4">已撤单</text>
					
				</view>
			</view>
			<view class="w-680 p-2 w-row-justify-between-align">
				<text class="font-26">订单编号</text><text class="w-wz-black8">{{item.orderid}}</text>
			</view>

			<view class="w-680 p-2 w-row-justify-between-align">
				<text class="font-26">订单类型</text>
				<view class="w-wz-cont" style="display: flex;align-items: center;">
				{{item.game_name}} | {{item.room_name}} | {{item.room_betname}}
				</view>
			</view>

			<view class="w-680 p-2 w-row-justify-between-align">
				<text class="font-26">下单号码</text><text class="w-wz-cont"><text
						class="p-2">{{item.number}}</text></text>
			</view>

			<view class="w-680 p-2 w-row-justify-between-align">
				<text class="font-26">金额倍数</text><text class="w-wz-gree">￥{{item.money}} | {{item.odds}}</text>
			</view>
			<!-- <view class="w-680 p-2 w-row-justify-between-align">
				<text class="font-26">投注赔率</text><text class="w-wz-red">{{item.odds}}</text>
			</view> -->
			<view class="w-680 p-2 w-row-justify-between-align">
				<text class="font-26">获得金额</text>
				<text v-if="item.status == 2" class="w-wz-gree">￥{{item.amoney}}</text>
				<text v-else class="w-wz-gree">0.00</text>
			</view>

			<view class="w-680 p-2 w-row-justify-between-align">
				<text class="font-26">订单时间</text><text class="w-wz-black8">{{item.create_time}}</text>
			</view>
			<view class="h-10"></view>
		</view>


        <view class="w-720 h-200 w-column-align m-top-50" v-if="tableData.length == 0">
        	<image class="wh-150" src="../../../static/gane/zwsj.png"></image>
        	<text class="w-wz-conts">暂 无 数 据 </text>
        </view>

		<view class="w-300 h-80  w-row-center w-bor-12">
			<text class="w-wz-conts font-28" v-if="isShow">没有数据了...</text>
		</view>
	
		<view class="wh-30"></view>
	</view>

</template>

<script>
	import $H from '@/pages/common/request.js'
	export default {
		data() {
			return {
				tableData: [],
				show: false,
				start_time: '',
				end_time: '',
				pagenum: 1,
				type: '',
				total: null,
				isShow: false,
				user_uid: '',
			}
		},

		onLoad(e) {
			const UserInfo = uni.getStorageSync('UserInfo');
			if (UserInfo.uid && UserInfo.token) {
				this.getUserAgentLog()
			} else {
				return uni.reLaunch({
					url: '/pages/index/index'
				});
			}
			if(e.user_uid){
				this.user_uid = e.user_uid
			}
		},

		onReachBottom() {

			uni.showLoading({
				title: '加载数据中...'
			});


			this.pagenum++
			let timer = setInterval(() => {
				uni.hideLoading();
				if (this.tableData.length == this.total) {
					this.isShow = true
				} else {
					this.getUserAgentLog()
				}
				clearTimeout(timer)
			}, 600);

		},

		methods: {

			changeTiem(val) {
				this.start_time = val[0]
				this.end_time = val[1]
				this.tableData = []
				this.getUserAgentLog(true)
			},

			getUserAgentLog(isBool) {
				$H.post('/app_user_order_list', {
					type: 'agent',
					pagenum: this.pagenum,
					start_time: this.start_time,
					end_time: this.end_time,
				}).then((res) => {
					console.log(res)
					if (res.code == 200) {
						if (isBool) {
							if (res.data.data.length == 0) {
								this.tableData = []
								this.isShow = true
							} else {
								this.tableData.push(...res.data.data)
							}
						} else {
							this.tableData.push(...res.data.data)
							this.total = res.data.total
							this.show = true
						}
					

					} else {
						return uni.showToast({
							title: res.msg,
							duration: 1000,
							icon: 'none'
						});
					}
				})
			},



		}
	}
</script>

<style>

</style>
